/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function addCourse(id)
{
    var xmlhttp;
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  xmlhttp.open("get", "../../common/addcourse?courseid="+id, true);
  //document.getElementById(id).innerHTML="unknown error occured";
  xmlhttp.send();
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      var xmlMessage=xmlhttp.responseXML;
      var valid=xmlMessage.getElementsByTagName("value")[0].firstChild.nodeValue;
      if(valid=="added")
          document.getElementById(id).innerHTML="course added";
      else if(valid=="failed")
          document.getElementById(id).innerHTML="already sent";
      else if(valid=="sent")
          document.getElementById(id).innerHTML="request sent";
      else
          document.getElementById(id).innerHTML="unknown error occured";
    }
  }
}